﻿@inherits BaseComponent

<KHeadList Class="kui-coding-form" ListTitle="字段信息">
    <Head>
        <KForm SmallLabel SmallRow>
            <KRow>
                <FieldItem Label="代码" Required>
                    <AntInput @bind-Value="Model.Code" />
                </FieldItem>
                <FieldItem Label="名称" Required>
                    <AntInput @bind-Value="Model.Name" />
                </FieldItem>
                <FieldItem Label="表前缀">
                    <AntInput @bind-Value="Model.Prefix" />
                </FieldItem>
                <FieldItem Label="命名空间">
                    <AntInput @bind-Value="Model.Namespace" />
                </FieldItem>
            </KRow>
            <KRow Size="28">
                <FieldItem Label="URL">
                    <AntInput @bind-Value="Model.PageUrl" />
                </FieldItem>
                <FieldItem Label="功能">
                    <AntCheckboxGroup @bind-Value="Model.Functions" Codes="Functions" />
                </FieldItem>
            </KRow>
        </KForm>
    </Head>
    <Toolbar>
        <KButton Icon="plus" Name="新建模型" OnClick="OnNew" />
        <KButton Icon="plus" Name="选择模型" OnClick="OnSelect" />
        <KButton Icon="save" Name="保存模型" OnClick="OnSave" />
        @* <KButton Icon="insert-row-above" Name="插入栏位" OnClick="OnInsert" /> *@
        <KButton Icon="plus" Name="添加栏位" OnClick="OnAdd" />
        <KButton Icon="plus" Name="快速添加" OnClick="OnAddPlus" />
        <KButton Icon="import" Name="导入表" OnClick="OnAddTable" Title="通过现有数据库表生成栏位。" />
        <KButton Icon="inbox" Name="粘贴" OnClick="OnPasteAsync" Title="复制Excel或者Markdown中如下列表字段顺序的表格文本，点击粘贴按钮即可。" />
    </Toolbar>
    <List>
        <CodeFieldTable DataSource="Model.Fields" HidePagination AutoHeight>
            <StringColumn Title="名称" Width="150" Fixed="ColumnFixPlacement.Left">
                <AntInput @bind-Value="context.Name" />
            </StringColumn>
            <StringColumn Title="代码" Width="150" Fixed="ColumnFixPlacement.Left">
                <AntInput @bind-Value="context.Id" />
            </StringColumn>
            <StringColumn Title="类型" Width="150">
                <FieldSelect @bind-Value="context.Type" />
            </StringColumn>
            <StringColumn Title="长度" Width="100">
                <AntInput @bind-Value="context.Length" />
            </StringColumn>
            <StringColumn Title="必填" Width="60">
                <AntSwitch @bind-Value="context.Required" />
            </StringColumn>
            <StringColumn Title="表格" Width="70">
                <AntSwitch @bind-Value="context.IsGrid" />
                @if (context.IsGrid) {
                    <AntIcon Type="more" Title="更多表格设置" OnClick="e=>OnGridSetting(context)" />
                }
            </StringColumn>
            <StringColumn Title="表单" Width="70">
                <AntSwitch @bind-Value="context.IsForm" />
                @if (context.IsForm) {
                    <AntIcon Type="more" Title="更多表单设置" OnClick="e=>OnFormSetting(context)" />
                }
            </StringColumn>
            <ActionColumn Title="操作" Align="ColumnAlign.Center" Width="150" Fixed="ColumnFixPlacement.Right">
                <KButton Name="上移" OnClick="e=>OnMoveUp(context)" />
                <KButton Name="下移" OnClick="e=>OnMoveDown(context)" />
                <KButton Name="删除" OnClick="e=>OnDelete(context)" Danger />
            </ActionColumn>
        </CodeFieldTable>
    </List>
</KHeadList>